package com.example.android.navigationdrawerexample;



//import java.awt.Checkbox;
import java.util.List;

import android.R.style;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;

import com.phonebrand.dao.DB4CommandDao;
import com.phonebrand.global.GlobalApplication;
import com.phonebrand.model.FlagObjM;

public class LoadTermAcitivity extends Activity {
	//private static final String LOG_TAG = "LoadTermAcitivity";
	private WebSettings webSettings;
	Button confirmBt;
	
	public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);		 
			setTheme(style.Theme_NoTitleBar);
			List<FlagObjM> listFlags = DB4CommandDao.getInstance().loadFlagObjM(((GlobalApplication)getApplication()).getDbPhone());
			
			if (listFlags != null && listFlags.size() > 0){													
				Intent intent = new Intent(LoadTermAcitivity.this,LoadPicScreen.class);										
				startActivity(intent);
				finish();	
			} else {
			
				setContentView(R.layout.term);			
				confirmBt = (Button)findViewById(R.id.confirmBt);									
				CheckBox checkAgree = (CheckBox)findViewById(R.id.checkAgree);						
				
				checkAgree.setOnCheckedChangeListener(new OnCheckedChangeListener() {
				    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
				        if ( isChecked ) {
				        	confirmBt.setVisibility(View.VISIBLE);
				        } else {
				        	confirmBt.setVisibility(View.INVISIBLE);
				        	
				        }			        
				    }
				});
				
				
				
				WebView myWebView = (WebView)findViewById(R.id.showTerm);
				myWebView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);   
				myWebView.setScrollbarFadingEnabled(false);   
				webSettings = myWebView.getSettings(); 
				webSettings.setBuiltInZoomControls(true);
				webSettings.setSupportZoom(true);
		//		webSettings.setDefaultZoom(ZoomDensity.FAR); 
				myWebView.loadUrl("file:///android_asset/www/term.html");		
				
				confirmBt.setOnClickListener(new OnClickListener() { 
					@Override
					public void onClick(View v) {
						// TODO Auto-generated method stub						
						Intent intent = new Intent(LoadTermAcitivity.this,LoadPicScreen.class);										
						startActivity(intent);
						finish();
					}
				});
			}	
	       			
	}
	

}
